<template>
	<view class="black">
		<image 
			:src="cover"
			mode="widthFix"
			class="cover"
			@longpress="operator"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cover:""
			}
		},
		onLoad(params) {
			this.cover = params.cover
			uni.setNavigationBarColor({
				frontColor:"#ffffff",
				backgroundColor:"#000000"
			})
		},
		methods: {
			operator(){
				var me = this
				// #ifndef H5
				uni.showActionSheet({
					itemList:["保存到本地"],
					success(res) {
						console.log(res)
						if(res.tapIndex == 0){
							// 下载
							console.log("下载")
							uni.showLoading({
								title:"保存中"
							})
							uni.downloadFile({
								url:me.cover,
								success(res2){
									console.log(res2.tempFilePath)
									uni.saveImageToPhotosAlbum({
										filePath:res2.tempFilePath,
										success() {
											uni.showToast({
												title:"保存成功",
												duration:2000
											})
										},
										complete() {
											uni.hideLoading()
										}
									})
								}
							})
						}
					}
				})
				// #endif
				
			}
		}
	}
</script>

<style>
.black{
	background-color: #000000;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	position: fixed;
}
.cover{
	align-self: center;
}
</style>
